#include "Quadrangle3D.h"



Quadrangle3D::Quadrangle3D(P3D a, P3D b, P3D c, P3D d)
{
	this->a = a;
	this->b = b;
	this->c = c;
	this->d = d;
}


Quadrangle3D::~Quadrangle3D()
{
}

Triangle3D* Quadrangle3D::ToTwoTriangle()
{
	Triangle3D* Ts = new Triangle3D[2];
	Ts[0] = Triangle3D(a, b, c);
	Ts[1] = Triangle3D(a, c, d);
	return Ts;
}

Vector3 Quadrangle3D::GetFaceNormal()
{
	Vector3 res = Vector3::CrossProduct(b.pos - a.pos, c.pos - a.pos);
	res.Identity();
	return res;
}

Vector3 Quadrangle3D::GetPointNormal()
{
	Vector3 res = (a.normal + b.normal + c.normal + d.normal) / 4;
	res.Identity();
	return res;
}
